#include "head.h"

void tcp(int * sock_fd, const char* ip, const char* port)
{
    *sock_fd = socket(AF_INET, SOCK_STREAM, 0);

    struct sockaddr_in addr;
    addr.sin_family = AF_INET;
    addr.sin_port = htons(atoi(port));
    addr.sin_addr.s_addr = inet_addr(ip);

    if(connect(*sock_fd, (struct sockaddr*)&addr, sizeof(addr)) == -1)
    {
        printf("未找到服务器\n");
        error(1, errno, "connect");
    }
    printf("已连接服务器\n");
}